#include<iostream>
#include<stdio.h>
// #include<cstdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include <thread>
#include <mutex>
#include<netdb.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<cstring>


using namespace std;

int main(int argc,char **argv){

   struct hostent *hostptr;
   //输出主机的别名
    char **pptr;
    char str[INET_ADDRSTRLEN];

   hostptr = gethostbyname("www.baidu.com");
   cout<<"主机名："<< hostptr->h_name<<endl;
   pptr = hostptr->h_addr_list;
            for (; *pptr!=NULL; pptr++) {
                printf("\taddress: %s ,IP address size is:%d\n",
                        inet_ntop(hostptr->h_addrtype, hostptr->h_addr, str, sizeof(str)),hostptr->h_length);
            }



   return 0;
}